var express = require('express');
const {handleRequest, handleRequestByCategoty, handleRequestByQueryRoom} = require("../service/rooms/findRooms");
const roomQueryAllError = require('../common/resultcode')
var router = express.Router();

/* GET home page. */
router.get('/', async function (req,
                                res,
                                next) {
    console.log('lail')

    handleRequest()
        .then((resp) => {
            res.send(resp)
        }).catch((e) => {
        res.send(roomQueryAllError)
    })
});
/**
 * 种类id查询 房间
 */
router.post('/findAllRoomsByCategoryId', async function (req,
                                res,
                                next) {
    console.log('lail')
    handleRequestByCategoty(req.body)
        .then((resp) => {
            res.send(resp)
        }).catch((e) => {
        res.send(roomQueryAllError)
    })
});
router.post('/findAllRoomsQueryRoom', async function (req,
                                                         res,
                                                         next) {
    console.log('房间')
    handleRequestByQueryRoom(req.body)
        .then((resp) => {
            res.send(resp)
        }).catch((e) => {
        res.send(roomQueryAllError)
    })
});
module.exports = router;